package com.b511.swpu.cementbackend.repository;

import com.b511.swpu.cementbackend.entity.MAIN_Person;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface MAIN_PersonRepository extends JpaRepository<MAIN_Person, String>,
        JpaSpecificationExecutor<MAIN_Person> {

    void deleteByRelationCode(String relationCode);

    MAIN_Person findByRelationCode(String relationCode);

    @Query(value = "select relationcode from main_person where relationcode=(select max (relationcode) from main_person)",nativeQuery = true)
    Integer findMaxRelationCode();

    @Query(value = "select * from main_person where code =:code",nativeQuery = true)
    MAIN_Person findByCode(@Param("code") String code);
}
